package com.juzi.inner.inner_anonymous;

/**
 * 目标：掌握匿名内部类的使用形式（语法）
 */
public class Test2 {
    public static void main(String[] args) {
        Swimming s = new Swimming() {
            @Override
            public void swim() {
                System.out.println("学生快乐的自由泳🏊‍");
            }
        };
        go(s);
        System.out.println("--------------------");
        Swimming t = new Swimming() {
            @Override
            public void swim() {
                System.out.println("老师游泳很快🏊‍");
            }
        };
        go(t);
        System.out.println("--------------------");

        go(new Swimming() {
            @Override
            public void swim() {
                System.out.println("运动员游泳很快🏊‍");
            }
        });
    }

    /**
     * 学生 老师 运动员 一起参加比赛
     */
    public static void go(Swimming s){
        System.out.println("比赛开始");
        s.swim();
        System.out.println("比赛结束");
    }
}

//class Student implements Swimming{
//
//    @Override
//    public void swim() {
//        System.out.println("学生快乐的自由泳🏊‍");
//    }
//}

interface Swimming{
    void swim();
}